﻿using Infrastructure.Attribute;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.DataCollection.ICommunication;
using ZR.DataCollection.InterfaceClass;
using ZR.DataCollection.SingleParameter;

namespace ZR.DataCollection.Execute
{
    /// <summary>
    // 设备点检
    /// </summary>
    [AppService(ServiceType = typeof(IExecuteWork), ServiceLifetime = LifeTime.Singleton)]
    public class ExecuteSpotCheckWorkI : IExecuteWork
    {
        public void ExecuteImport()
        {
            if (CurrentAppInfo.Current.InterfaceCommExtend == null)
            {
                CurrentAppInfo.Current.InterfaceCommExtend.CommunicationDataCallback += CommunicationDefault_plc_dataChange;
            }
        }

        public void CommunicationDefault_plc_dataChange(string stationType, INormCommunication communication, int itemNo, string address, object value)
        {
            //点检逻辑
            if (itemNo.Equals(10) && Convert.ToInt16(value).Equals(1))//假设
            {
                //条件
                if (true)
                {
                    communication.WriteValue(100, 1);//假设
                }
                else
                {
                    communication.WriteValue(100, 0);//假设
                }
            }
        }
    }
}